package com.app.repository.impl;

import com.app.model.main.Accusation;
import com.app.repository.interfaces.AccusationMapper;
import com.app.support.dao.MybatisDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by Lichaojie on 2017/3/12. It's a beautiful day.
 */
@Repository
public class AccusationMapperImpl implements AccusationMapper {

    @Autowired
    private MybatisDao mybatisDao;

    @Override
    public int deleteByPrimaryKey(Long id){
        return mybatisDao.delete("com.app.dao.main.AccusationMapper",".deleteByPrimaryKey",id);
    }

    @Override
    public int insert(Accusation record){
        return mybatisDao.insert("com.app.dao.main.AccusationMapper", ".insert", record);
    }

    @Override
    public int insertSelective(Accusation record){
        return mybatisDao.insert("com.app.dao.main.AccusationMapper",".insertSelective",record);
    }

    @Override
    public Accusation selectByPrimaryKey(Long id){
        return mybatisDao.get("com.app.dao.main.AccusationMapper", ".selectByPrimaryKey", id);
    }

    @Override
    public Accusation selectByParam(long senderId, String time){
        Map<String,Object> map = new HashMap<>();
        map.put("senderId",senderId);
        map.put("time",time);
        return mybatisDao.get("com.app.dao.main.AccusationMapper",".selectByParam",map);
    }

    @Override
    public int updateByPrimaryKeySelective(Accusation record){
        return mybatisDao.update("com.app.dao.main.AccusationMapper",".updateByPrimaryKey",record);
    }

    @Override
    public int updateByPrimaryKey(Accusation record){
        return mybatisDao.update("com.app.dao.main.AccusationMapper",".updateByPrimaryKey",record);
    }
}
